﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Core.Base
{
    /// <summary>
    /// 不为空检测
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public sealed class NotNull<T>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="value"></param>
        public NotNull(T value)
        {
            this.Value = value;
        }

        /// <summary>
        /// 值
        /// </summary>
        public T Value { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        public static implicit operator NotNull<T>(T value)
        {
            if (value == null)
                throw new ArgumentNullException();
            return new NotNull<T>(value);
        }
    }
}
